package com.sgcc.nfc.lock.data.remote.dto.log

import com.google.gson.annotations.SerializedName
import com.sgcc.nfc.lock.domain.model.OperationLog

data class OperationLogDto(
    @SerializedName("logId") val logId: Long?,
    @SerializedName("operationType") val operationType: Int?,
    @SerializedName("userId") val userId: Long?,
    @SerializedName("userName") val userName: String?,
    @SerializedName("regionId") val regionId: Long?,
    @SerializedName("lockId") val lockId: Long?,
    @SerializedName("lockNfcId") val lockNfcId: String?,
    @SerializedName("roomId") val roomId: Long?,
    @SerializedName("roomName") val roomName: String?,
    @SerializedName("longitude") val longitude: Double?,
    @SerializedName("latitude") val latitude: Double?,
    @SerializedName("operationTime") val operationTime: String?,
    @SerializedName("remark") val remark: String?
) {
    fun toDomain(): OperationLog = OperationLog(
        logId = logId ?: 0L,
        operationType = operationType ?: 0,
        userId = userId,
        userName = userName,
        regionId = regionId,
        lockId = lockId,
        lockNfcId = lockNfcId,
        roomId = roomId,
        roomName = roomName,
        longitude = longitude,
        latitude = latitude,
        operationTime = operationTime,
        remark = remark
    )
}
